package com.smartwork.common.mobile.wechat.servlet;

import com.smartwork.common.mobile.wechat.thread.JsapiTicketThread;
import com.smartwork.common.mobile.wechat.thread.TokenThread;
import com.smartwork.common.mobile.wechat.util.WeixinConfUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import java.util.Iterator;
import java.util.Set;

public class InitServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void init() throws ServletException {
        super.init();
        Set<String> groupIds = WeixinConfUtils.getGroupIds();
        Iterator<String> it = groupIds.iterator();
        while (it.hasNext()) {
            String groupId = it.next();
            // 启动定时获取access_token的线程
            new Thread(new TokenThread(groupId)).start();
            // 启动定时获取JsapiTicket的线程
            new Thread(new JsapiTicketThread(groupId)).start();
        }

	}
}
